package org.webball.tools;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import org.webball.base.interfaces.IList;
/**
 * List that contains players logins.
 * Used to actualize players connected to server on client side. 
 * @author Marcin Kaczor
 *
 */
public class PlayersList implements IList {
	private List<String> list = null;
	/**
	 * initializes empty list
	 */
	public PlayersList() {
		list = new LinkedList<String>();
	}
	/**
	 * Copies values from specified list.
	 * @param list
	 * - not <code>null</code>
	 */
	@Override
	public void copy(IList l) {
		list.clear();
		Iterator<String> it = l.getList().iterator();
		while(it.hasNext()) {
			list.add(it.next());
		}
	}

	@Override
	public void setList(List<String> l) {
		list = l;
		
	}

	@Override
	public List<String> getList() {
		return list;
	}
	
	public void addPlayer(String name){
		list.add(name);
	}
	
	public void removePlayer(String name){
		list.remove(name);
	}
}
